/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Lager;

import javax.swing.*;
import java.awt.event.*;
import javax.swing.JList;

import java.util.*;
import javax.swing.*;
import javax.swing.event.*;  // ListSelectionListener
import java.awt.*;
/**
 *
 * @author SPAWN
 */
public class Configuration extends JFrame implements ListSelectionListener{

     private JPanel panel = new JPanel ();
     private JButton neu = null;
     private JButton loeschen = null;
     private JButton hinzufuegen = null;
     private JLabel Teil;
     private JLabel Typ;
     private JTextField akutelleAuswahl;

     private String inhalt[] = new String[10];
     private JScrollPane listPane = null;
     private JList liste = null;

     private String inhalt2[] = new String[5];
     private String inhalt3[] = new String[5];
     private String inhalt4[] = new String[15];

     private JScrollPane listPane2 = null;
     private JList liste2 = null;



    public Configuration()
        {
                initComponents();
        }


    void initComponents()
        {
            panel.setLayout(null);
            this.setTitle("Verwaltung");
            this.addWindowListener(new WindowListener());
            this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

            inhalt[0] = "Karosserie";
            inhalt[1] = "Fahrwerk";
            inhalt[2] = "Räder";
            inhalt[3] = "Dach";
            inhalt[4] = "Spoiler";
            inhalt[5] = "Farbe";
            inhalt[6] = "Felgen";

            inhalt2[0] = "normal";
            inhalt2[1] = "luxus";
            inhalt2[2] = "extravagant";


            inhalt3[0] = "sport";
            inhalt3[1] = "normal";
            inhalt3[2] = "rentner";

            inhalt4[0] = "2";
            inhalt4[1] = "3";
            inhalt4[2] = "4";
            inhalt4[3] = "5";
            inhalt4[4] = "6";
            inhalt4[5] = "7";
            inhalt4[6] = "8";
            inhalt4[7] = "9";
            inhalt4[8] = "10";
            inhalt4[9] = "11";
            inhalt4[10] = "12";
            inhalt4[11] = "13";
            inhalt4[12] = "14";
            inhalt4[13] = "15";
            inhalt4[14] = "16";



            Teil = new JLabel("Teil");
            Teil.setBounds(40, 10, 35,50);
            panel.add(Teil);

            Typ = new JLabel("Typ");
            Typ.setBounds(325, 10, 35,50);
            panel.add(Typ);

       /*     akutelleAuswahl = new JTextField("leer");
            akutelleAuswahl.setBounds(250, 250, 100,30);
            panel.add(akutelleAuswahl);*/

        liste = new JList(inhalt);
	listPane = new JScrollPane(liste);
	listPane.setBounds(40, 50, 200, 200);
	panel.add(listPane);
        listPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        liste.addListSelectionListener( this );

        liste2 = new JList();
	listPane2 = new JScrollPane(liste2);
	listPane2.setBounds(325, 50, 200, 200);
	panel.add(listPane2);
        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);



          //  String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

            neu = new JButton("neu");
            neu.setBounds(20, 300, 150, 35);
            panel.add(neu);

            loeschen = new JButton("Löschen");
            loeschen.setBounds(220, 300, 150, 35);
            panel.add(loeschen);

            hinzufuegen = new JButton("Hinzufügen");
            hinzufuegen.setBounds(420, 300, 150, 35);
            panel.add(hinzufuegen);

            setTitle("Auswahl der Teilkonfiguration");
            add(panel);
            pack();
            setSize(600, 400);
            this.setResizable(false);
            setVisible(true);
        }

/*
    public void valueChanged(ListSelectionEvent e) {
		// Aenderungen in der Listenauswahl
		if ( e.getSource()==liste
				&& !e.getValueIsAdjusting() ) {
			akutelleAuswahl.setText(
					liste.getSelectedValue().toString() );
		}
	} */






        public void valueChanged(ListSelectionEvent e) {
		// Aenderungen in der Listenauswahl
		if ( "Karosserie"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList(inhalt2);
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

		}

                if ( "Fahrwerk"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList(inhalt3);
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}

                 if ( "RÃ¤der"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList(inhalt4);
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}

                if ( "Dach"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList();
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}

                if ( "Farbe"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList();
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}

                if ( "Spoiler"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList();
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}

                if ( "Felgen"==liste.getSelectedValue().toString() && !e.getValueIsAdjusting() ) {
			liste2 = new JList();
                        listPane2 = new JScrollPane(liste2);
                        listPane2.setBounds(325, 50, 200, 200);
                        panel.add(listPane2);
                        listPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}
	}












    class WindowListener extends WindowAdapter {
                public void windowClosing(WindowEvent event) {

                }
        }

}